from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage
from test_case.options import options


class Personal(BasePage):
    url = r'/bsams/front/asset_storage/asset_storage_list.do'
    # 修改电话号码
    mod_phone_loc = (By.ID, 'phone')
    mod_ok_loc = (By.CLASS_NAME, 'button_fujian')
    # 修改密码
    mod_btn_loc = (By.LINK_TEXT, '修改密码')
    mod_oldPassword_loc = (By.ID, 'oldPassword')
    mod_newPassword1_loc = (By.ID, 'newPassword1')
    mod_newPassword2_loc = (By.ID, 'newPassword2')
    mod_sure_loc = (By.XPATH, '//*[@id="cboxLoadedContent"]/div/div/div[2]/div[4]/div[1]')

    def mod_phone(self, phone):
        self.open()

        self.ele_clear(self.mod_phone_loc)
        self.inpit_ele(self.mod_phone_loc, phone)
        self.ele_click(self.mod_ok_loc)
        sleep(3)

    def mod_password(self, oldPassword, newPassword1, newPassword2):
        self.open()
        self.ele_click(self.mod_btn_loc)
        self.ele_clear(self.mod_oldPassword_loc)
        self.input_ele(self.mod_oldPassword_loc, oldPassword)
        self.ele_clear(self.mod_newPassword1_loc)
        self.input_ele(self.mod_newPassword1_loc, newPassword1)
        self.ele_clear(self.mod_newPassword2_loc)
        self.input_ele(self.mod_newPassword1_loc, newPassword2)
        self.ele_click(self.mod_sure_loc)
        sleep(3)
